<?php 
if( trim($data) == date('d/m/Y') )
{
    $data = 'Hoje '.$data;
}
?>
<table id="tabela-calendario">
    <thead>
        <tr>
            <td colspan="2" id="bt-novo-compromisso">
                <span class="left block" id="calendario-data-escolhida"><?php echo $data; ?></span>
                <?php echo $html->link('Novo Compromisso', '#', array('class' => 'right')); ?>
            </td> 
        </tr>
    </thead>
    <tbody>
        <?php
        if(count($arrCompromisso) > 0)
        {
            $sAlerta = "Compromisso(s) do dia: \\n\\n";
            $bAlerta = false;
            foreach($arrCompromisso as $compromisso)
            {
                $sHoraInicio = substr($compromisso['comp_hora_inicio'],0,5);
                $sHoraFim = (trim($compromisso['comp_hora_fim']) != '') ? substr($compromisso['comp_hora_fim'],0,5) : '';
                $sLocal = (trim($compromisso['comp_local']) != '') ? ' ('.$compromisso['comp_local'].')' : '';

                if($compromisso['comp_alerta']=="1")
                {
                    $bAlerta = true;
                    if(!(($sHoraInicio=="00:00")&&($sHoraFim=="00:00"))) 
                       $sAlerta = $sAlerta.$sHoraInicio." - ".$sHoraFim."  ";
                    else
                       $sAlerta = $sAlerta."Sem horário  ";
                    $sAlerta = $sAlerta.$compromisso['comp_nome']." ".$sLocal."\\n";
                }
                ?>
                <tr>
                        <td><?php if(!(($sHoraInicio=="00:00")&&($sHoraFim=="00:00"))) echo $sHoraInicio." - ".$sHoraFim; ?></td>
                        <td><?php echo $compromisso['comp_nome']." ".$sLocal; ?></td>
                </tr>
                <?php
            }
            if(($_SESSION['mostrar_alerta'] == true)&&($bAlerta==true))
            {
                $_SESSION['mostrar_alerta'] = false;
                echo "<script>alert('".$sAlerta."')</script>";
            }
        }
        else
        {  
            ?>
            <tr>
                <td colspan="2"><small>Não há compromissos para este dia.</small></td>
            </tr>
            <?php
        }
        ?>       
    </tbody>
</table>